package com.kaibai.dao.impl;

import com.kaibai.dao.BaseDao;
import com.kaibai.dao.OrderItemDao;
import com.kaibai.pojo.OrderItem;

import java.sql.Connection;
import java.util.List;

public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {
    @Override
    public int saveOrderItem(Connection conn, OrderItem orderItem) {
        String sql = "insert into t_order_item(name,count,price,total_price,order_id) values(?,?,?,?,?)";
        return update(conn,sql,orderItem.getName(),orderItem.getCount(),orderItem.getPrice(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemsByOrderId(Connection conn,String orderid) {
        String sql = "select name,count,price,total_price totalPrice,order_id orderId from t_order_item where order_id=?";
        return getForList(conn,OrderItem.class,sql,orderid);
    }


}
